#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
    unordered_map<char, int> mp, hashmp;
    string str, broken;
    int cnt = 1, k;
    cin >> k >> str;
    for (int i = 1; i <= str.length(); i++) {
        if(str[i] != str[i - 1]) {
            if (cnt % k != 0)mp[str[i - 1]] = 1;
            cnt = 1;
        } 
        else{
            cnt++;
            if (cnt == k && mp[str[i - 1]] != 1) {
                mp[str[i - 1]] = 0;
            }
        }
    }
    for (int i = 0; i < str.length(); i++) {
        if (mp[str[i]] != 1 && hashmp[str[i]] != 1) {
            printf("%c", str[i]);
            hashmp[str[i]] = 1;
        }
    }
    printf("\n");
    for (int i = 0; i < str.length(); i++) {
        if (mp[str[i]] == 1) {
            printf("%c", str[i]);
            cnt = 1;
        } else {
            cnt++;
            if (cnt % k == 0)printf("%c", str[i]);
        }
    }
    return 0;
}
